// Copyright (c) 2008 Matthew Johnson
// Licensed under the MIT License (see license.txt)
package actionml.animation {
	import actionml.Global;
	class ExpressionRenderer extends RendererBase {
		protected var _expression:Object;
		protected var _property:String
		public function ExpressionRenderer(target:Object, property:String, expression:Object) {
			_target = target.getValueForKeypath(property["withoutLastPart"]());
			_property = property["lastPart"]();
			if (expression is String) {
				_expression = expression.replace(/^{|}$/g, "").compileExpression();
			} else {
				_expression = expression;
			}
		}
		public override function get name():String {
			return _property;
		}
		public override function get rendering():Boolean {
			return true;
		}
		public override function render(rc:RenderContext) {	
			_target.setValueForKeypath(_property, _target.evaluateExpression(_expression));
		}
	}
}
